#include<stdio.h>
#include<string.h>

char *str_reverse(char *str);
int my_atoi(char *str);

int main(int argc, char *argv[]){
	char str[] = "helloworld!!!";
	int num;
	char num1[] = "123";

	str_reverse(str);
	puts(str);
	puts(num1);
	num = my_atoi(num1);
	printf("%d\n", num);

	return 0;
}

char *str_reverse(char *str){
	int i,j;
	char t;
	for(i = 0, j = strlen(str)-1; i < j; i++, j--){
		memcpy(&t, str + i, sizeof(char));
		memcpy(str + i, str + j, sizeof(char));
		memcpy(str + j, &t, sizeof(char));
	}
	return str;
}


int my_atoi(char *str){
	int num = 0;
	int i = 0;

	while(str[i]){
		num = num*10 + (str[i] - '0');
		i++;
	}
	return num;
}
